<template>
  <div>
    <el-row :gutter="15">
      <el-form
        ref="elForm"
        :model="timeZoneForm"
        size="medium"
        label-width="110px"
        label-position="left"
        :rules="rules"
      >
        <el-col :span="13">
          <div class="tab-line colorBlue">
            <div>时区设置</div>
          </div>
        </el-col>
        <el-col :span="13">
          <el-form-item label="时区选择" class="ml-20">
            <el-select
              v-model="timeZoneForm.timezone_id"
              placeholder="请选择时区"
              style="width: 100%;"
            >
              <el-option
                v-for="item in TimezoneList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
              <!-- <el-option key="2" label="GMT-13:00" value="2" /> -->
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="13">
          <el-form-item label="夏令时" class="ml-20">
            <el-switch
              v-model="timeZoneForm.iAutoDst"
              :active-value="activeValue"
              :inactive-value="inactiveValue"
              v-isNormal
            >
            </el-switch>
          </el-form-item>
        </el-col>
        <el-col :span="13">
          <el-form-item label="日期格式" class="ml-20">
            <el-select
              v-model="timeZoneForm.daylight_mode"
              @change="change"
              type="number"
              placeholder="请选择"
              :disabled="disabledTimeSet"
              >
              <el-option label="日期" :value="1"></el-option>
              <el-option label="星期" :value="2"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="开启日期" class="ml-20">
            <el-select
              v-model="timeZoneForm.daylight_start_month"
              @change="change"
              type="number"
              placeholder="请选择"
              :disabled="disabledTimeSet"
              >
              <el-option label="一月" :value="0"></el-option>
              <el-option label="二月" :value="1"></el-option>
              <el-option label="三月" :value="2"></el-option>
              <el-option label="四月" :value="3"></el-option>
              <el-option label="五月" :value="4"></el-option>
              <el-option label="六月" :value="5"></el-option>
              <el-option label="七月" :value="6"></el-option>
              <el-option label="八月" :value="7"></el-option>
              <el-option label="九月" :value="8"></el-option>
              <el-option label="十月" :value="9"></el-option>
              <el-option label="十一月" :value="10"></el-option>
              <el-option label="十二月" :value="11"></el-option>
            </el-select>
            <el-select
              v-if="timeZoneForm.daylight_mode == 1"
              v-model="timeZoneForm.daylight_start_month_day"
              @change="change"
              class="ml-20"
              type="number"
              placeholder="请选择"
              :disabled="disabledTimeSet"
              >
              <el-option label="1" :value="1"></el-option>
              <el-option label="2" :value="2"></el-option>
              <el-option label="3" :value="3"></el-option>
              <el-option label="4" :value="4"></el-option>
              <el-option label="5" :value="5"></el-option>
              <el-option label="6" :value="6"></el-option>
              <el-option label="7" :value="7"></el-option>
              <el-option label="8" :value="8"></el-option>
              <el-option label="9" :value="9"></el-option>
              <el-option label="10" :value="10"></el-option>
              <el-option label="11" :value="11"></el-option>
              <el-option label="12" :value="12"></el-option>
              <el-option label="13" :value="13"></el-option>
              <el-option label="14" :value="14"></el-option>
              <el-option label="15" :value="15"></el-option>
              <el-option label="16" :value="16"></el-option>
              <el-option label="17" :value="17"></el-option>
              <el-option label="18" :value="18"></el-option>
              <el-option label="19" :value="19"></el-option>
              <el-option label="20" :value="20"></el-option>
              <el-option label="21" :value="21"></el-option>
              <el-option label="22" :value="22"></el-option>
              <el-option label="23" :value="23"></el-option>
              <el-option label="24" :value="24"></el-option>
              <el-option label="25" :value="25"></el-option>
              <el-option label="26" :value="26"></el-option>
              <el-option label="27" :value="27"></el-option>
              <el-option label="28" :value="28"></el-option>
              <el-option label="29" :value="29"></el-option>
              <el-option label="30" :value="30"></el-option>
              <el-option label="31" :value="31"></el-option>
            </el-select>
            <el-select
              v-if="timeZoneForm.daylight_mode == 2"
              v-model="timeZoneForm.daylight_start_week"
              @change="change"
              class="ml-20"
              type="number"
              placeholder="请选择"
              :disabled="disabledTimeSet"
              >
              <el-option label="第一个" :value="1"></el-option>
              <el-option label="第二个" :value="2"></el-option>
              <el-option label="第三个" :value="3"></el-option>
              <el-option label="第四个" :value="4"></el-option>
              <el-option label="第五个" :value="5"></el-option>
            </el-select>
            <el-select
              v-if="timeZoneForm.daylight_mode == 2"
              v-model="timeZoneForm.daylight_start_week_day"
              @change="change"
              class="ml-20"
              type="number"
              placeholder="请选择"
              :disabled="disabledTimeSet"
              >
              <el-option label="周一" :value="1"></el-option>
              <el-option label="周二" :value="2"></el-option>
              <el-option label="周三" :value="3"></el-option>
              <el-option label="周四" :value="4"></el-option>
              <el-option label="周五" :value="5"></el-option>
              <el-option label="周六" :value="6"></el-option>
              <el-option label="周日" :value="0"></el-option>
            </el-select>
            <el-time-picker
              v-model="timeZoneForm.daylight_start_time"
              class="ml-20"
              format="HH:mm"
              value-format="HH:mm"
              @input="changeDate"
              :disabled="disabledTimeSet"
              placeholder="选择时间">
            </el-time-picker>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="结束日期" class="ml-20">
            <!-- <el-col :span="6"> -->
            <el-select
              v-model="timeZoneForm.daylight_end_month"
              @change="change"
              type="number"
              placeholder="请选择"
              :disabled="disabledTimeSet"
              >
              <el-option label="一月" :value="0"></el-option>
              <el-option label="二月" :value="1"></el-option>
              <el-option label="三月" :value="2"></el-option>
              <el-option label="四月" :value="3"></el-option>
              <el-option label="五月" :value="4"></el-option>
              <el-option label="六月" :value="5"></el-option>
              <el-option label="七月" :value="6"></el-option>
              <el-option label="八月" :value="7"></el-option>
              <el-option label="九月" :value="8"></el-option>
              <el-option label="十月" :value="9"></el-option>
              <el-option label="十一月" :value="10"></el-option>
              <el-option label="十二月" :value="11"></el-option>
            </el-select>
            <el-select
              v-if="timeZoneForm.daylight_mode == 1"
              v-model="timeZoneForm.daylight_end_month_day"
              @change="change"
              class="ml-20"
              type="number"
              placeholder="请选择"
              :disabled="disabledTimeSet"
              >
              <el-option label="1" :value="1"></el-option>
              <el-option label="2" :value="2"></el-option>
              <el-option label="3" :value="3"></el-option>
              <el-option label="4" :value="4"></el-option>
              <el-option label="5" :value="5"></el-option>
              <el-option label="6" :value="6"></el-option>
              <el-option label="7" :value="7"></el-option>
              <el-option label="8" :value="8"></el-option>
              <el-option label="9" :value="9"></el-option>
              <el-option label="10" :value="10"></el-option>
              <el-option label="11" :value="11"></el-option>
              <el-option label="12" :value="12"></el-option>
              <el-option label="13" :value="13"></el-option>
              <el-option label="14" :value="14"></el-option>
              <el-option label="15" :value="15"></el-option>
              <el-option label="16" :value="16"></el-option>
              <el-option label="17" :value="17"></el-option>
              <el-option label="18" :value="18"></el-option>
              <el-option label="19" :value="19"></el-option>
              <el-option label="20" :value="20"></el-option>
              <el-option label="21" :value="21"></el-option>
              <el-option label="22" :value="22"></el-option>
              <el-option label="23" :value="23"></el-option>
              <el-option label="24" :value="24"></el-option>
              <el-option label="25" :value="25"></el-option>
              <el-option label="26" :value="26"></el-option>
              <el-option label="27" :value="27"></el-option>
              <el-option label="28" :value="28"></el-option>
              <el-option label="29" :value="29"></el-option>
              <el-option label="30" :value="30"></el-option>
              <el-option label="31" :value="31"></el-option>
            </el-select>
            <el-select
              v-if="timeZoneForm.daylight_mode == 2"
              v-model="timeZoneForm.daylight_end_week"
              @change="change"
              class="ml-20"
              type="number"
              placeholder="请选择"
              :disabled="disabledTimeSet"
              >
              <el-option label="第一个" :value="1"></el-option>
              <el-option label="第二个" :value="2"></el-option>
              <el-option label="第三个" :value="3"></el-option>
              <el-option label="第四个" :value="4"></el-option>
              <el-option label="第五个" :value="5"></el-option>
            </el-select>
            <el-select
              v-if="timeZoneForm.daylight_mode == 2"
              v-model="timeZoneForm.daylight_end_week_day"
              @change="change"
              class="ml-20"
              type="number"
              placeholder="请选择"
              :disabled="disabledTimeSet"
              >
              <el-option label="周一" :value="1"></el-option>
              <el-option label="周二" :value="2"></el-option>
              <el-option label="周三" :value="3"></el-option>
              <el-option label="周四" :value="4"></el-option>
              <el-option label="周五" :value="5"></el-option>
              <el-option label="周六" :value="6"></el-option>
              <el-option label="周日" :value="0"></el-option>
            </el-select>
            <el-time-picker
              v-model="timeZoneForm.daylight_end_time"
              format="HH:mm"
              value-format="HH:mm"
              class="ml-20"
              @input="changeDate"
              :disabled="disabledTimeSet"
              placeholder="选择时间">
            </el-time-picker>
          </el-form-item>
        </el-col>
        <el-col :span="13">
          <el-form-item label="偏移时间" class="ml-20" prop="daylight_offset">
            <el-slider v-model="timeZoneForm.daylight_offset" show-input  :disabled="disabledTimeSet"></el-slider>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item size="large" class="ml-20">
            <el-button
              type="primary"
              size="medium"
              style="width: 120px"
              @click="submitForm('elForm')"
              >保存</el-button
            >
          </el-form-item>
        </el-col>
      </el-form>
      <el-form
        ref="el2Form"
        :model="form"
        size="medium"
        label-width="110px"
        label-position="left"
        :rules="rules2"
      >
        <el-col :span="13">
          <div class="tab-line colorBlue">
            <div>NTP设置</div>
          </div>
        </el-col>
        <el-col :span="13">
          <el-form-item label="启用NTP校时" class="ml-20">
            <el-select
              v-model="form.iAutoMode"
              type="number"
              placeholder="请选择"
              >
              <el-option label="开启" :value="1"></el-option>
              <el-option label="关闭" :value="0"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="13">
          <el-form-item label="NTP地址" prop="sNtpServers" class="ml-20">
            <el-input
              class="input"
              v-model="form.sNtpServers"
            ></el-input>
            </el-form-item>
          <el-form-item v-if="false">
            <el-radio-group v-model="form.iAutoModeType" disabled >
              <el-radio class="radioBox" :label="1" v-if="false">
                <el-form-item label="NTP地址">
                  <el-input
                    class="input"
                    v-model="form.sNtpServers"
                  ></el-input>
                </el-form-item>
              </el-radio>
              <el-radio class="radioBox" :label="2" v-if="false">
                <el-form-item label="云平台">
                  <el-input
                    class="input"
                    v-model="form.sAiotServer"
                  ></el-input>
                </el-form-item>
              </el-radio>
              <el-radio class="radioBox" :label="3" v-if="false">
                <el-form-item label="第三方平台">
                  <el-input
                    class="input"
                    v-model="form.sThirdpartyServer"
                  ></el-input>
                </el-form-item>
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="13">
          <el-form-item label="校准间隔" prop="iRefreshTime" class="ml-20">
            <el-input
              v-model="form.iRefreshTime"
              type="number"
              placeholder="请输入校准间隔"
              :style="{ width: '100%' }"
              @input="numberChange(arguments[0], 60)"
            >
              <template slot="append">分钟</template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item size="large" class="ml-20">
            <el-button
              type="primary"
              size="medium"
              style="width: 120px"
              @click="submit2Form('elForm')"
            >
              保存
            </el-button>
            <!-- <el-button @click="resetForm">重置</el-button> -->
          </el-form-item>
        </el-col>
        <hr>
        <el-col :span="13">
          <el-form-item label="设备时间" prop="devTime" class="ml-20">
            <el-input
              v-model="form.devTime"
              placeholder="请输入设备时间"
              :style="{ width: '100%' }"
              disabled
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="13">
          <el-form-item label="本地时间" prop="time" class="ml-20">
            <el-date-picker
              @input="onInput()"
              :clearable="false"
              v-model="form.time"
              type="datetime"
              placeholder="选择日期时间"
              :style="{ width: '100%' }"
              :value-format="'yyyy-MM-dd HH:mm:ss'"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item size="large" class="ml-20">
            <el-button
              v-if="false"
              type="primary"
              size="medium"
              style="width: 120px;"
            >
            刷新
            </el-button>
            <el-button
              type="primary"
              size="medium"
              style="width: 120px;"
              @click="asyncDate"
            >
            同步本地时间
            </el-button>
          </el-form-item>
          <label class="save-tips ml-20">注意：修改时间可能导致登录过期！</label>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>

<script>
import {
  getTimezoneApi,
  getTimezoneListApi,
  setTimezoneApi,
  getSystemNetworkApi,
  getSystemNetworkTimeApi,
  editSystemNetworkApi,
  editSystemNetworkTimeApi,
} from "@/api/access/equipment";
import $ from 'jquery'

export default {
  props: {},
  watch: {
    form: {
      handler(val) {},
    },
  },
  data() {
    const scopeRange = (rule, value, callback) => {
      let ywReg = /^[A-Za-z.]+$/
      let numberReg = /^[0-9.]+$/
      let ipReg = /^((2(3[0-3]|[0-2]\d))|1\d{1,2}|[1-9]\d|[1-9])(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){2}(\.((2(5[0-4]|[0-4]\d))|1\d{1,2}|[1-9]\d|[1-9]))$/;
      let urlReg = /^(?:\.[\w\.-]+)+[\w\-\._~:/[\]@!\$&'\*\+,;=.]+$/;
      if (isNaN(Number(value))) {
        if (value.charAt(0) >= 0) {
          if(!ipReg.test(value)){
            callback(new Error("请输入合法IP"));
          }else{
            callback();
          }
        } else {
          if(urlReg.test(value)){
            callback(new Error("请输入合法网址"));
          }else{
            callback();
          }
        }
        if(value.length>32){
          callback(new Error("长度不能超过32位"));
        }else{
          callback();
        }
      } else {
        callback();
      }
    };
    return {
      activeValue: 1,
      inactiveValue: 0,
      TimezoneList: [],
      form: {
        time: '',
        devTime: '',
      },
      timeZoneForm: {
        timezone_id: '',
        iAutoDst: 0,
        daylight_mode: 1,
        daylight_offset: 1,
      },
      rules: {
        timezone_id: [
          {required: true, message: "时区不能为空", trigger: "blur"},
        ],
        daylight_offset: [
          {required: true, message: "输出音量不能为空", trigger: "blur"},
          { pattern:/^[0-9]*$/, trigger: "blur", message: '请输入正整数' },
        ],
      },
      rules2: {
        sNtpServers: [
          {required: true, message: "请输入NTP地址", trigger: "blur"},
          {required: true, trigger: "blur", validator: scopeRange},
        ],
        iRefreshTime: [
          {
            trigger: "change",
            required: true,
            message: "请输入校准间隔",
          },
          {
            required: true,
            pattern: /^(?:[1-9]|[1-5]\d|60)$/,
            message: "只能输入1-60区间的整数",
            trigger: ["blur", "change"],
          },
        ],
        // time: [
        //   {
        //     trigger: "change",
        //     required: true,
        //     message: "请输入时间",
        //   },
        // ],
      },
      syncTime: false, // 同步时间
      timeOut: null,
      timeOut2: null,
    };
  },
  created() {
    this.getTimezoneList();
    this.getSysteamNet();
  },
  methods: {
    change() {
      this.$forceUpdate()
    },
    changeDate() {
      this.$forceUpdate()
    },
    numberChange(val, maxNum) {
      //转换数字类型
      this.form.iRefreshTime = Number(val);
      //重新渲染
      this.$nextTick(() => {
        //比较输入的值和最大值，返回小的
        let num = Math.min(Number(val), maxNum);
        //输入负值的情况下， = 0（可根据实际需求更该）
        if (num < 0) {
          this.form.iRefreshTime = 1;
        } else {
          //反之
          this.form.iRefreshTime = num;
        }
      });
    },
    onInput() {
      this.$forceUpdate();
    },
    submitForm() {
      this.$refs.elForm.validate((valid) => {
        if (valid) {
          console.log(288, this.timeZoneForm);
          let params = { ...this.form };
          for (const i in this.TimezoneList) {
            if (this.TimezoneList[i].value === this.timeZoneForm.timezone_id) {
              params.timezone = this.TimezoneList[i].utc.substring(1, this.TimezoneList[i].utc.length-1);
            }
          }
          params.timezone_id = this.timeZoneForm.timezone_id;
          params.iAutoDst = !this.timeZoneForm.iAutoDst ? 0 : this.timeZoneForm.iAutoDst;
          params.daylight_mode = !this.timeZoneForm.daylight_mode ? 1 : this.timeZoneForm.daylight_mode*1;
          params.daylight_start_month = this.timeZoneForm.daylight_start_month;
          params.daylight_start_month_day = this.timeZoneForm.daylight_start_month_day;
          params.daylight_end_month = this.timeZoneForm.daylight_end_month;
          params.daylight_end_month_day = this.timeZoneForm.daylight_end_month_day;
          params.daylight_start_week = this.timeZoneForm.daylight_start_week;
          params.daylight_start_week_day = this.timeZoneForm.daylight_start_week_day;
          params.daylight_end_week = this.timeZoneForm.daylight_end_week;
          params.daylight_end_week_day = this.timeZoneForm.daylight_end_week_day;
          let start_time = this.timeZoneForm.daylight_start_time.split(':');
          console.log(11, start_time);
          params.daylight_start_hour = start_time[0]*1;
          params.daylight_start_minute = start_time[1]*1;
          let end_time = this.timeZoneForm.daylight_end_time.split(':');
          console.log(22, start_time);
          params.daylight_end_hour = end_time[0]*1;
          params.daylight_end_minute = end_time[1]*1;
          params.daylight_offset = this.timeZoneForm.daylight_offset;
          delete params.devTime;
          delete params.iAutoMode;
          delete params.iRefreshTime;
          delete params.iTimeZoneId;
          delete params.sNtpServers;
          delete params.daylight_start_time;
          delete params.daylight_end_time;
          delete params.sTimeZone;
          delete params.sTimeZoneFileDst;
          delete params.time;
          console.log(311, params);
          let p1 = new Promise((resolve, reject) => {
            setTimezoneApi(params)
              .then((res) => {
                // resolve(res);
                this.$message.success("保存成功");
              })
              .catch((err) => {
                // resolve(err);
                this.$message.error("保存失败");
              });
          });
        }
      });
    },
    submit2Form() {
      this.$refs.el2Form.validate((valid) => {
        if (valid) {
          let params = { ...this.form };
          delete params.syncTime;
          // let p2 = new Promise((resolve, reject) => {
          //   editSystemNetworkTimeApi({ time: params.time.replace(/ /, "T") })
          //     .then((res) => {
          //       clearTimeout(this.timeOut);
          //       let time = res.time ? res.time.replace(/T/, " ") : "";
          //       this.getNowTime(time);
          //       resolve(res);
          //     })
          //     .catch((err) => {
          //       resolve(err);
          //     });
          // });

          let p1 = new Promise((resolve, reject) => {
            editSystemNetworkApi(params)
              .then((res) => {
                // resolve(res);
                this.$message.success("保存成功");
              })
              .catch((err) => {
                // resolve(err);
                this.$message.error("保存失败");
              });
          });

          // Promise.all([p1, p2]).then((res) => {
          //   this.$message.success("保存成功");
          // });
        }
      });
    },
    resetForm() {},
    // 获取网络
    getSysteamNet() {
      let self = this;
      getSystemNetworkApi().then((res) => {
        this.form = Object.assign({}, this.form, res);
        // console.log(this.form);
      });
      getTimezoneApi().then((res) => {
        console.log(374, res);
        this.form = Object.assign({}, this.form, res);
        this.timeZoneForm.timezone_id = res.timezone_id
        this.timeZoneForm.daylight_mode = res.daylight_mode === 0 ? 1 : res.daylight_mode
        this.timeZoneForm.iAutoDst = res.iAutoDst
        this.timeZoneForm.daylight_start_month = res.daylight_start_month
        this.timeZoneForm.daylight_start_month_day = res.daylight_start_month_day
        this.timeZoneForm.daylight_end_month = res.daylight_end_month
        this.timeZoneForm.daylight_end_month_day = res.daylight_end_month_day
        this.timeZoneForm.daylight_start_week = res.daylight_start_week
        this.timeZoneForm.daylight_start_week_day = res.daylight_start_week_day
        this.timeZoneForm.daylight_end_week = res.daylight_end_week
        this.timeZoneForm.daylight_end_week_day = res.daylight_end_week_day
        this.timeZoneForm.daylight_start_time = res.daylight_start_hour + ':' + res.daylight_start_minute
        this.timeZoneForm.daylight_end_time = res.daylight_end_hour + ':' + res.daylight_end_minute
        this.timeZoneForm.daylight_offset = res.daylight_offset
        // console.log(this.form);
      });

      getSystemNetworkTimeApi().then((res) => {
        this.form.devTime = res.time ? res.time.replace(/T/, " ") : "";
        // console.log(310, this.form.time);
        if (this.formatDate().length > 0) {
          this.form.time = this.formatDate();
        }
        // console.log(312, this.form.devTime);
        this.getNowTime(this.form.devTime, 'devTime');
        this.getNowTime(this.form.time, 'time');
      });

      let DevTimeRun = setInterval(() => {
        getSystemNetworkTimeApi().then((res) => {
          this.form.devTime = res.time ? res.time.replace(/T/, " ") : "";
          // console.log(310, this.form.time);
          if (this.formatDate().length > 0) {
            this.form.time = this.formatDate();
          }
          // console.log(312, this.form.devTime);
          this.getNowTime(this.form.devTime, 'devTime');
          this.getNowTime(this.form.time, 'time');
        });
      }, 10000);
    },
    // 获取时区
    getTimezoneList() {
      getTimezoneListApi().then((res) => {
        console.log(346, res);
        this.TimezoneList = res;
        this.TimezoneList.forEach((item) => {
          item.label = item.utc + "   " + item.name;
        });
      });
    },
    getNowTime(hasTime, str) {
      let timestamp = this.$moment(hasTime).valueOf() / 1000;
        timestamp += 1;
        let time = this.$moment(timestamp * 1000).format("YYYY-MM-DD HH:mm:ss");
        // this.$set(this.form, "time", time);
        this.$set(this.form, str, time);
    },
    formatDate() {
      let now = new Date();
      let year = now.getFullYear();
      let month = now.getMonth() + 1 < 10 ? '0' + (now.getMonth() + 1) : now.getMonth() + 1;
      let day = now.getDate() < 10 ? '0' + now.getDate() : now.getDate();
      let hour = now.getHours() < 10 ? '0' + now.getHours() : now.getHours();
      let minute = now.getMinutes() < 10 ? '0' + now.getMinutes() : now.getMinutes();
      let second = now.getSeconds() < 10 ? '0' + now.getSeconds() : now.getSeconds();
      return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
    },
    asyncDate() {
      // if (this.form.syncTime) {
        let params = { ...this.form };
        delete params.syncTime;
        let p2 = new Promise((resolve, reject) => {
          editSystemNetworkTimeApi({ time: params.time.replace(/ /, "T") })
          .then((res) => {
            clearTimeout(this.timeOut);
            let time = res.time ? res.time.replace(/T/, " ") : "";
            this.getNowTime(time);
            resolve(res);
            this.$message.success("同步本地时间成功");
          })
          .catch((err) => {
            resolve(err);
          });
        })
        // this.form.time = this.$moment().format("YYYY-MM-DD HH:mm:ss");
        // this.timeOut2 = setInterval(() => {
        //   this.form.time = this.$moment().format("YYYY-MM-DD HH:mm:ss");
        // }, 1000);
        // this.$message.success("同步本地时间成功");
      // } else {
      //   clearTimeout(this.timeOut2);
      // }
    },
  },
  computed: {
    disabledTimeSet() {
      return this.timeZoneForm.iAutoDst === 0;
    },
  },
  destroyed() {
    clearTimeout(this.timeOut);
  },
};
</script>

<style lang="scss" scoped>
.tab-line.colorBlue {
  background-color: #C6E2FF;
}
.tab-line {
  height: 40px;
  display: flex;
  justify-content: space-between;
  background-color: #f9f9f9;
  align-items: center;
  padding: 0 20px;
  margin-bottom: 10px;
  .status-icon {
    position: relative;
    cursor: pointer;
    &::after {
      position: absolute;
      content: "";
      left: -10px;
      top: -10px;
      width: 20px;
      height: 20px;
      border-width: 1px;
      border-style: solid;
      border-color: #006eff;
      border-radius: 50%;
    }
  }
  .actives {
    &::before {
      position: absolute;
      content: "";
      left: -6px;
      top: -6px;
      width: 12px;
      height: 12px;
      background-color: #006eff;
      border-radius: 50%;
    }
  }
}
.radioBox {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  .input {
    width: 300px;
  }
}
.save-tips {
  color: #fd3939;
}
.ml-20 {
  margin-left: 20px;
}
</style>
